<template>
  <Dialog 
  :title="dialogTitle" 
  v-model="dialogVisible"
  :close-on-click-modal ="false"
  :close-on-press-escape = "false"
  @close="handleClose"
  >
    <el-form
      ref="formRef"
      :rules="formRules"
      label-width="100px"
      v-loading="formLoading"
    />
    <PDFView :pdf-url="url" :show-all="true"/>
    <template #footer>
      <!-- <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button> -->
      <el-button @click="handleClose">取 消</el-button>
    </template>
  </Dialog>
</template>
<script setup lang="ts">
import PDFView from '../resumeinfo/ResumePdfView.vue'
import { JobResumeInfoApi } from '@/api/dbit/jobresumeinfo'

/** 简历投递 表单 */
defineOptions({ name: 'JobResumeInfoForm' })



const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用

const formRules = reactive({
})

const url = ref('');

/** 打开弹窗 */
const open = async (obj:any) => {
  dialogVisible.value = true
  dialogTitle.value = '在线预览'
  // 修改时，设置数据
  url.value = obj.resumePath
  // 如果投递状态是1:未查看,修改该投递信息的状态，修改为已读
  if(obj.jobResumeStatus === 1){
    await JobResumeInfoApi.updateJobResumeInfoStatus(obj.id, 0)
  }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗

const emit = defineEmits(['closed']);
const handleClose = () => {
  dialogVisible.value = false
  emit('closed');
};



</script>